package com.bwie.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TbDraw;
import com.bwie.service.TbDrawService;
import com.bwie.mapper.TbDrawMapper;
import com.bwie.utils.R;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Date;
import java.util.List;

/**
* @author 叶雨洁
* @description 针对表【tb_draw】的数据库操作Service实现
* @createDate 2025-07-01 08:52:15
*/
@Slf4j
@Service
public class TbDrawServiceImpl extends ServiceImpl<TbDrawMapper, TbDraw>
    implements TbDrawService{



    @Autowired
    TbDrawMapper drawMapper;
    @Override
    public R getDrawList() {
        //显示抽奖列表

        List<TbDraw> tbDraws = drawMapper.selectList(null);

        log.info("抽奖列表",JSON.toJSONString(tbDraws));
        return R.OK(tbDraws);
    }

    @Override
    public R Adddraw(TbDraw tbDraw) {

        tbDraw.setCreateTime(new Date());
        drawMapper.insert(tbDraw);
        return R.OK();
    }

    @Override
    public R deleteDraw(Integer drawId) {

        drawMapper.deleteById(drawId);
        return R.OK();
    }

    @Override
    public R updateDraw(TbDraw tbDraw) {

        tbDraw.setCreateTime(new Date());
        drawMapper.updateById(tbDraw);
        return R.OK();
    }


}




